// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   CreateJFile.java

package include.nseer_cookie;

import include.nseer_db.nseer_db;
import java.io.*;
import java.sql.ResultSet;
import java.util.Timer;
import java.util.TimerTask;

public class CreateJFile
{
	class CAd extends TimerTask
	{

		private String c;
		final CreateJFile this$0;

		public void run()
		{
			try
			{
				nseer_db erp_db = new nseer_db(dbase);
				String sql = "select id from erpPlatform_config_public_char where kind='nseer_file_1' and type_name='js' and all_tag='0'";
				ResultSet rs = erp_db.executeQuery(sql);
				if (rs.next())
				{
					sql = (new StringBuilder("update erpPlatform_config_public_char set used_tag='0' where kind='nseer_file_1' and type_name='js' and describe2='")).append(times).append("'").toString();
					erp_db.executeUpdate(sql);
					sql = "select describe1 from erpPlatform_config_public_char where kind='nseer_file_1' and type_name='js' and used_tag='0'";
					rs = erp_db.executeQuery(sql);
					if (rs.next())
						c = rs.getString("describe1");
					BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream((new StringBuilder(String.valueOf(path))).append("javascript/include/nseer_cookie/ad.js").toString()), "UTF-8"));
					out.write(c);
					out.flush();
					out.close();
					if (times == 3)
						times = 0;
					else
						times++;
				}
			}
			catch (Exception ex)
			{
				ex.printStackTrace();
			}
		}

		CAd()
		{
			this$0 = CreateJFile.this;
			super();
			c = "";
		}
	}

	class DAd extends TimerTask
	{

		final CreateJFile this$0;

		public void run()
		{
			try
			{
				String sql = "update erpPlatform_config_public_char set used_tag='1' where kind='nseer_file_1' and type_name='js'";
				nseer_db erp_db = new nseer_db(dbase);
				erp_db.executeUpdate(sql);
				File f = new File((new StringBuilder(String.valueOf(path))).append("javascript/include/nseer_cookie/ad.js").toString());
				f.delete();
			}
			catch (Exception ex)
			{
				ex.printStackTrace();
			}
		}

		DAd()
		{
			this$0 = CreateJFile.this;
			super();
		}
	}


	private BufferedReader file;
	private String path;
	private String dbase;
	private int times;

	public CreateJFile()
	{
		times = 0;
	}

	public void create(String filePath, String db)
		throws FileNotFoundException
	{
		try
		{
			path = filePath;
			String a = "";
			String b = "";
			dbase = db;
			String sql = "select describe1 from erpPlatform_config_public_char where kind='nseer_file' and type_name='js'";
			nseer_db erp_db = new nseer_db(dbase);
			ResultSet rs = erp_db.executeQuery(sql);
			if (rs.next())
				a = rs.getString("describe1");
			sql = "select describe1 from erpPlatform_config_public_char where kind='nseer_file_1' and type_name='js'";
			rs = erp_db.executeQuery(sql);
			if (rs.next())
				b = rs.getString("describe1");
			sql = "update erpPlatform_config_public_char set all_tag='0' where kind='nseer_file_1' and type_name='js'";
			erp_db.executeUpdate(sql);
			erp_db.close();
			BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream((new StringBuilder(String.valueOf(filePath))).append("javascript/include/nseergrid/nseergrid.js").toString()), "UTF-8"));
			out.write(a);
			out.flush();
			out.close();
			times = 0;
			Timer timer = new Timer(true);
			timer.schedule(new CAd(), 1L, 0x6ddd00L);
			timer.schedule(new DAd(), 0x493e1L, 0x6ddd00L);
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}




}
